<?php
include('../../inc/global.inc');
$url=$_SERVER['HTTP_REFERER'];
?>
<?php
if($_POST[tj_act]){
$time1=$_POST[add_year]."-".$_POST[add_month]."-".$_POST[add_day];
$type_id=explode("@",$_POST[type_id]);
$p_rs=mysql_query("select * from city where id='$_POST[c_provinces]' and city_id=0");
$p_row=mysql_fetch_array($p_rs);
$c_rs=mysql_query("select * from city where id='$_POST[c_city]' and c_dj=2");
$c_row=mysql_fetch_array($c_rs);
$c_city=($_POST[c_city])?$_POST[c_city]:0;
$n_sh=$_POST[n_sh]?$_POST[n_sh]:0;
$n_tj=$_POST[n_tj]?$_POST[n_tj]:0;
mysql_query("insert into news (news_title,type_id,type_name,type_id2,type_name2,pro_id,pro_name,city_id,city_name,news_content,news_time,n_sh,n_tj) values ('$_POST[news_title]','1','三帝招标','$type_id[0]','$type_id[1]','$_POST[c_provinces]','$p_row[city_name]','$c_city','$c_row[city_name]','$_POST[news_content]','$time1','$n_sh','$n_tj')");
echo "<script>alert('发布成功');location='zhaobiao.php';</script>";
}
?>
<?php
if($_POST['xg_act']){
$time1=$_POST[add_year]."-".$_POST[add_month]."-".$_POST[add_day];
$type_id=explode("@",$_POST[type_id]);
$p_rs=mysql_query("select * from city where id='$_POST[c_provinces]' and city_id=0");
$p_row=mysql_fetch_array($p_rs);
$c_rs=mysql_query("select * from city where id='$_POST[c_city]' and c_dj=2");
$c_row=mysql_fetch_array($c_rs);
$c_city=($_POST[c_city])?$_POST[c_city]:0;
$n_sh=$_POST[n_sh]?$_POST[n_sh]:0;
$n_tj=$_POST[n_tj]?$_POST[n_tj]:0;
mysql_query("update news set news_title='$_POST[news_title]',type_id2='$type_id[0]',type_name2='$type_id[1]',pro_id='$_POST[c_provinces]',pro_name='$p_row[city_name]',city_id='$c_city',city_name='$c_row[city_name]',news_content='$_POST[news_content]',n_sh='$n_sh',n_tj='$n_tj',news_time='$time1' where id='".$_POST['iid']."'");
echo "<script>alert('修改成功');location='".$_POST['urls']."';</script>";
}
?>
<HTML>
<HEAD>
<TITLE>Admin</TITLE>
<META http-equiv=Content-Type content="text/html; charset=utf-8">
<LINK href="../css/css.css" rel=stylesheet>
<script type='text/javascript' src="../js/islogin.js" charset="gb2312"></script>
<script language="javascript" src="/js/city.js" type="text/javascript" charset="gb2312"></script>
<BODY>
<center>
<table width="90%" border="0" cellpadding="0" cellspacing="1" bgcolor="#000000">
  <tr>
    <td height="25" bgcolor="#EEEEF9" style="padding-left:5px;">三帝招标&nbsp;&nbsp;<a href="javascript:history.go(-1)">返回</a></td>
  </tr>
</table>
<?php
if($_GET[tj]){
?>
<table width="90%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#000000">
<form method="post" action="" onSubmit="return check()" name="form1">
    <tr>
      <td height="30" colspan="3" align="center" bgcolor="#8DA8CF"><strong>发布招标信息</strong></td>
    </tr>
  <tr>
    <td width="23%" height="25" align="center" bgcolor="#8DA8CF">招标主题</td>
    <td width="77%" bgcolor="#FFFFFF" style="padding-left:4px;"><input name="news_title" type="text" size="50"></td>
  </tr>
  <tr>
    <td height="25" align="center" bgcolor="#8DA8CF">招标分类</td>
	<td bgcolor="#FFFFFF" style="padding-left:4px;">
<select name="type_id" id="type_id">
<option value="">--选择招标分类--</option>    
<?    
$t_rs= mysql_query("select * from news_type where type_id=1");    
while($t_row=mysql_fetch_array($t_rs)){    
?>    
<option value="<?=$t_row[id]?>@<?=$t_row[type_name]?>"><?=$t_row[type_name]?></option> 
<? } ?>    
</select>     
</td>
  </tr>
    <tr>
    <td height="25" align="center" bgcolor="#8DA8CF">选择城市</td>
	<td bgcolor="#FFFFFF" style="padding-left:4px;"><select name="c_provinces" onChange="changecity(document.form1.c_provinces.options[document.form1.c_provinces.selectedIndex].value)">
<option value="">--选择省份--</option>    
<?    
$rs01=mysql_query("select * from city where city_id=0 order by order_name asc");    
while($res=mysql_fetch_array($rs01)){    
?>    
<option value="<?=$res['id']?>"><?=$res['city_name']?></option> 
<? } ?>    
</select>     
<select name="c_city" id="c_city">                    
  <option value="">--选择城市--</option>
</select></td>
  </tr>
  <tr>
    <td height="25" align="center" bgcolor="#8DA8CF">详细内容</td>
    <td bgcolor="#FFFFFF" style="padding-left:4px;"><?php echo fck($value,'news_content');?></td>
  </tr>
  <tr>
    <td height="25" align="center" bgcolor="#8DA8CF">发布时间</td>
    <td bgcolor="#FFFFFF" style="padding-left:4px;"><input name="add_year" type="text" size="3" value="<?=date("Y",time())?>"> - <input name="add_month" type="text" size="2" value="<?=date("m",time())?>"> 
    - <input name="add_day" type="text" size="2" value="<?=date("d",time())?>"></td>
  </tr>
  <tr>
    <td height="25" align="center" bgcolor="#8DA8CF">信息设置</td>
    <td bgcolor="#FFFFFF" style="padding-left:4px;">是否显示 <input name="n_sh" type="checkbox" value="1" checked>&nbsp;&nbsp;是否推荐 <input name="n_tj" type="checkbox" value="1"></td>
  </tr>
  <tr><input type="hidden" name="tj_act" value="ok">
    <td height="25" colspan="2" align="center" bgcolor="#FFFFFF"><input type="submit" value="提交"></td>
    </tr>
  </form>
</table>
<?php }?>
<?php
if($_GET['xg']){
$rs=mysql_query("select * from news where id='".$_GET['xg_id']."'");
$row=mysql_fetch_array($rs);
?>
<table width="90%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#000000">
<form method="post" action="" name="form1">
    <tr>
      <td height="30" colspan="3" align="center" bgcolor="#8DA8CF"><strong>修改招标信息</strong></td>
    </tr>
  <tr>
    <td width="23%" height="25" align="center" bgcolor="#8DA8CF">招标主题</td>
    <td width="77%" bgcolor="#FFFFFF" style="padding-left:4px;"><input name="news_title" type="text" size="50" value="<?=$row[news_title]?>"></td>
  </tr>
  <tr>
    <td height="25" align="center" bgcolor="#8DA8CF">招标分类</td>
    <td bgcolor="#FFFFFF" style="padding-left:4px;">
  <select name="type_id" id="type_id">
<option value="">--选择招标分类--</option>    
<?    
$t_rs= mysql_query("select * from news_type where type_id=1");    
while($t_row=mysql_fetch_array($t_rs)){    
?>    
<option value="<?=$t_row[id]?>@<?=$t_row[type_name]?>" <?php if($row[type_id2]==$t_row[id]){echo "selected";}?> ><?=$t_row[type_name]?></option>
<? } ?>    
</select></td>
  </tr>
      <tr>
    <td height="25" align="center" bgcolor="#8DA8CF">选择城市</td>
	<td bgcolor="#FFFFFF" style="padding-left:4px;"><select name="c_provinces" onChange="changecity(document.form1.c_provinces.options[document.form1.c_provinces.selectedIndex].value)">
<option value="">--选择省份--</option>    
<?    
$rs01=mysql_query("select * from city where city_id=0 order by order_name asc");    
while($res=mysql_fetch_array($rs01)){    
?>    
<option value="<?=$res['id']?>" <?php if($row[pro_id]==$res[id]){echo "selected";}?>><?=$res['city_name']?></option> 
<? } ?>    
</select>     
<select name="c_city" id="c_city">                    
  <option value="">--选择城市--</option>
  			<?php
			$rs2=mysql_query("select * from city where city_id='$row[pro_id]' order by id asc");
			while($row2=mysql_fetch_array($rs2)){
			?>
			<option value="<?=$row2['id']?>" <?php if($row[city_id]==$row2[id]){echo "selected";}?>><?=$row2['city_name']?></option>
			<?php
			}?>  
</select></td>
  </tr>
  <tr>
    <td align="center" bgcolor="#8DA8CF">详细内容</td>
    <td bgcolor="#FFFFFF" style="padding-left:4px;"><?php echo fck($row[news_content],'news_content');?></td>
  </tr>
  <tr>
    <td height="25" align="center" bgcolor="#8DA8CF">发布时间</td>
    <td bgcolor="#FFFFFF" style="padding-left:4px;"><input name="add_year" type="text" size="4" value="<?=substr($row[news_time],0,4)?>"> - <input name="add_month" type="text" size="2" value="<?=substr($row[news_time],5,2)?>"> - <input name="add_day" type="text" size="2" value="<?=substr($row[news_time],8,2)?>"></td>
  </tr>
  <tr>
    <td height="25" align="center" bgcolor="#8DA8CF">信息设置</td>
    <td bgcolor="#FFFFFF" style="padding-left:4px;">是否显示 <input name="n_sh" type="checkbox" value="1" <?php if($row[n_sh]==1){echo "checked";}?>>&nbsp;&nbsp;是否推荐 <input name="n_tj" type="checkbox" value="1" <?php if($row[n_tj]==1){echo "checked";}?>></td>
  </tr>
  <tr><input type="hidden" name="xg_act" value="ok"><input type="hidden" name="urls" value="<?=$url?>">
  <input type="hidden" name="iid" value="<?=$row['id']?>">
    <td height="25" colspan="2" align="center" bgcolor="#FFFFFF"><input type="submit" value="提交"></td>
    </tr>
  </form>
</table>
<?php }?>
</center>
</BODY>
</HTML>

<script language="javascript">
function $(id){
   return document.getElementById(id);
  }
function check(){
  if($("news_title").value==""){
     alert("招标主题不能为空");
     $("news_title").focus();
     return false;
}
if($("type_id").value==""){
     alert("招标分类不能为空");
     $("type_id").focus();
     return false;
}
if($("c_provinces").value==""){
     alert("省份不能为空");
     $("c_provinces").focus();
     return false;
}
}
</script>